package cn.jbooter.shiro.autoconfigure.util;


import javax.servlet.http.HttpServletResponse;

import cn.jbooter.coms.constants.IBaseConstants;
import cn.jbooter.coms.pojos.Page;
import cn.jbooter.coms.utils.WebUtil;


public class ShiroUtil {

	/**
	 * 向客户端写登陆失败json信息
	 * @param msg
	 */
	public static void writeLoginFail(String failmsg,HttpServletResponse response) {
		Page<?> page = new Page<>();
		page.setCode(IBaseConstants.AUTHC_FAIL_CODE);
		page.setMsg(failmsg);
		page.setSuccess(false);
		WebUtil.writeJson(response, page);
	}
	
	/**
	 * 向客户端写操作成功的json信息
	 * @param succmsg
	 * @param response
	 */
	public static void writeSuccess(String succmsg,HttpServletResponse response) {
		Page<?> page = new Page<>();
		page.setCode(IBaseConstants.SUCCESS_CODE);
		page.setMsg(succmsg);
		page.setSuccess(true);
		WebUtil.writeJson(response, page);
	}
	
	/**
	 * 向客户端写授权失败的json信息
	 */
	public static void writeAuthzFail(String failmsg,HttpServletResponse response) {
		Page<?> page = new Page<>();
		page.setCode(IBaseConstants.AUTHZ_FAIL_CODE);
		page.setMsg(failmsg);
		page.setSuccess(false);
		WebUtil.writeJson(response, page);
	}
	
	
}
